<%@ page contentType="text/html;charset=GBK" %>
<%@ page import="java.util.*" %>
<%@ page import="com.ionglobal.db.*" %>
<%@ page import="com.ionglobal.lib.*" %>
<%@ page import="com.ionglobal.cms.*" %>
<%@ page import="com.ionglobal.misc.*" %>

<%@ include file="../init_include.jsp" %>

<%
	
	Sysop sysop=(Sysop)session.getAttribute("sysop");
	if ( sysop==null)
	{
		dbi.closeAll();
		return;
	}
		
	String sql="",tmpStr="";
	
	String name=dbi.fixSql(request.getParameter("name"));
	String description=dbi.fixSql(request.getParameter("description"));
	
	SysRole newRole=SysRole.getSysRole(dbi,name);
	if (newRole!=null)
	{
		out.println(" Sorry! role <b>"+name+"</b> has exists<br>");
		dbi.closeAll();
		return;
	}
	
	for ( int i=0;i<9;i++)
	{	
		if (request.getParameter("checkbox"+String.valueOf(i))!=null)
		tmpStr+="1";
		else
		tmpStr+="0";
	}
	
	 	long sequenceid = SequenceManager.getNextValue(dbi,"sys_role_seq");

		sql ="insert into sys_role (id,name,permission,modulecode) values ("+sequenceid+",'";
		sql+=name+"','"+tmpStr+"','BMS')";
		SysRole.insertRole(dbi,sql);
		response.sendRedirect("sysRoleManager.jsp");
%>	
<%@ include file="../init_free.jsp" %>

